home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / archiver / ice_240.lzh / ICE_UNPA.S < prev    next >
Text File  |  1994-08-27  |  3KB  |  163 lines

  1. ;********************************************* unpacking routine of PACK-ICE
  2. ; a0 = Pointer to packed data
  3. ; a1 = Address to which the data is unpacked
  4. ; "bsr" of "jsr" to ice_decrunch with registers a0 and a1 prepared.
  5. ice_decrunch:
  6.     movem.l    d0-a6,-(sp)
  7.     bsr.s    getinfo
  8.     cmpi.l    #'ICE!',d0
  9.     bne    not_packed
  10.     bsr.s    getinfo    
  11.     lea.l    -8(a0,d0.l),a5
  12.     bsr.s    getinfo
  13.     move.l    d0,(sp)
  14.     move.l    a1,a4
  15.     move.l    a1,a6
  16.     adda.l    d0,a6
  17.     move.l    a6,a3
  18.     move.b    -(a5),d7
  19.     bsr    normal_bytes
  20.  
  21.     move.l    a3,a6
  22.     bsr    get_1_bit
  23.     bcc.s    not_packed
  24.     move.w    #$0f9f,d7
  25.     bsr    get_1_bit
  26.     bcc.s    ice_00
  27.     moveq    #15,d0    
  28.     bsr    get_d0_bits
  29.     move.w    d1,d7
  30. ice_00:    moveq    #3,d6
  31. ice_01:    move.w    -(a3),d4
  32.     moveq    #3,d5
  33. ice_02:    add.w    d4,d4
  34.     addx.w    d0,d0
  35.     add.w    d4,d4
  36.     addx.w    d1,d1
  37.     add.w    d4,d4
  38.     addx.w    d2,d2
  39.     add.w    d4,d4
  40.     addx.w    d3,d3
  41.     dbra    d5,ice_02
  42.     dbra    d6,ice_01
  43.     movem.w    d0-d3,(a3)
  44.     dbra    d7,ice_00
  45.  
  46. not_packed:
  47.     movem.l    (sp)+,d0-a6
  48.     rts
  49.  
  50. getinfo:    moveq    #3,d1
  51. getbytes: lsl.l    #8,d0
  52.     move.b    (a0)+,d0
  53.     dbf    d1,getbytes
  54.     rts
  55.  
  56. normal_bytes:    
  57.     bsr.s    get_1_bit
  58.     bcc.s    test_if_end
  59.     moveq.l    #0,d1
  60.     bsr.s    get_1_bit
  61.     bcc.s    copy_direkt
  62.     lea.l    direkt_tab+20(pc),a1
  63.     moveq.l    #4,d3
  64. nextgb:    move.l    -(a1),d0
  65.     bsr.s    get_d0_bits
  66.     swap.w    d0
  67.     cmp.w    d0,d1
  68.     dbne    d3,nextgb
  69. no_more:    add.l    20(a1),d1
  70. copy_direkt:    
  71.     move.b    -(a5),-(a6)
  72.     dbf    d1,copy_direkt
  73. test_if_end:    
  74.     cmpa.l    a4,a6
  75.     bgt.s    strings
  76.     rts    
  77.  
  78.  
  79. get_1_bit:add.b    d7,d7
  80.     bne.s    bitfound
  81.     move.b    -(a5),d7
  82.     addx.b    d7,d7
  83. bitfound:    rts    
  84.  
  85. get_d0_bits:    
  86.     moveq.l    #0,d1
  87. hole_bit_loop:    
  88.     add.b    d7,d7
  89.     bne.s    on_d0
  90.     move.b    -(a5),d7
  91.     addx.b    d7,d7
  92. on_d0:    addx.w    d1,d1
  93.     dbf    d0,hole_bit_loop
  94.     rts    
  95.  
  96.  
  97.  
  98. strings:    lea.l    length_tab(pc),a1
  99.     moveq.l    #3,d2
  100. get_length_bit:    
  101.     bsr.s    get_1_bit
  102.     dbcc    d2,get_length_bit
  103. no_length_bit:    
  104.     moveq.l    #0,d4
  105.     moveq.l    #0,d1
  106.     move.b    1(a1,d2.w),d0
  107.     ext.w    d0
  108.     bmi.s    no_über
  109. get_über: bsr.s    get_d0_bits
  110. no_über:    move.b    6(a1,d2.w),d4
  111.     add.w    d1,d4
  112.     beq.s    get_offset_2
  113.  
  114.  
  115.     lea.l    more_offset(pc),a1
  116.     moveq.l    #1,d2
  117. getoffs:    bsr.s    get_1_bit
  118.     dbcc    d2,getoffs
  119.     moveq.l    #0,d1
  120.     move.b    1(a1,d2.w),d0
  121.     ext.w    d0
  122.     bsr.s    get_d0_bits
  123.     add.w    d2,d2
  124.     add.w    6(a1,d2.w),d1
  125.     bpl.s    depack_bytes
  126.     sub.w    d4,d1
  127.     bra.s    depack_bytes
  128.  
  129.  
  130. get_offset_2:    
  131.     moveq.l    #0,d1
  132.     moveq.l    #5,d0
  133.     moveq.l    #-1,d2
  134.     bsr.s    get_1_bit
  135.     bcc.s    less_40
  136.     moveq.l    #8,d0
  137.     moveq.l    #$3f,d2
  138. less_40:    bsr.s    get_d0_bits
  139.     add.w    d2,d1
  140.  
  141. depack_bytes:
  142.     lea.l    2(a6,d4.w),a1
  143.     adda.w    d1,a1
  144.     move.b    -(a1),-(a6)
  145. dep_b:    move.b    -(a1),-(a6)
  146.     dbf    d4,dep_b
  147.     bra    normal_bytes
  148.  
  149.  
  150. direkt_tab:
  151.     dc.l $7fff000e,$00ff0007,$00070002,$00030001,$00030001
  152.     dc.l     270-1,    15-1,     8-1,     5-1,     2-1
  153.  
  154. length_tab:
  155.     dc.b 9,1,0,-1,-1
  156.     dc.b 8,4,2,1,0
  157.  
  158. more_offset:
  159.     dc.b      11,   4,   7,  0
  160.     dc.w    $11f,  -1, $1f
  161.  
  162. ;************************************************* end of unpacking routine
  163.